﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Adams.Public.Web.Areas.Membership.Controllers
{
    [Authorize]
    [EnsureSsl]
    public class ProfileController : Controller
    {
        [AppendLayoutViewModel]
        public ActionResult Index()
        {
            string token = User.Identity.Name;
            var model = Adams.Public.Web.Business.Web.Areas.Membership.Profile.Index.PageLoad(token);
            return View(model);
        }

        [AppendLayoutViewModel]
        public ActionResult Email()
        {

            string token = User.Identity.Name;
            var model = Adams.Public.Web.Business.Web.Areas.Membership.Profile.Email.PageLoad(token);
            return View(model);
        }

        [AppendLayoutViewModel]
        public ActionResult Password()
        {

            string token = User.Identity.Name;
            var model = Adams.Public.Web.Business.Web.Areas.Membership.Profile.Password.PageLoad(token);
            return View(model);
        }

        [AppendLayoutViewModel]
        public ActionResult General()
        {

            string token = User.Identity.Name;
            var model = Adams.Public.Web.Business.Web.Areas.Membership.Profile.General.PageLoad(token);
            return View(model);
        }

        [AppendLayoutViewModel]
        public ActionResult CreditCard()
        {
            string token = User.Identity.Name;
            var model = Adams.Public.Web.Business.Web.Areas.Membership.Profile.CreditCard.PageLoad(token);
            model.ReturnTo = Request["r"];
            return View(model);
        }

        public JsonResult SaveEmail(Adams.Public.DataTransfer.Profile.SaveEmailInput input)
        {
            string token = User.Identity.Name;
            var model = Adams.Public.Web.Business.Web.Areas.Membership.Profile.Email.SaveEmail(token, input);
            return Json(model);
        }

        public JsonResult SaveGeneral(Adams.Public.DataTransfer.Profile.SaveGeneralInput input)
        {
            string token = User.Identity.Name;
            var model = Adams.Public.Web.Business.Web.Areas.Membership.Profile.General.SaveGeneral(token, input);
            return Json(model);
        }

        public JsonResult SavePassword(Adams.Public.DataTransfer.Profile.SavePasswordInput input)
        {
            string token = User.Identity.Name;
            var model = Adams.Public.Web.Business.Web.Areas.Membership.Profile.Password.SavePassword(token, input);
            return Json(model);
        }

        public JsonResult SaveCreditCard(Adams.Public.DataTransfer.Profile.SaveCreditCardInput input)
        {
            string token = User.Identity.Name;
            var model = Adams.Public.Web.Business.Web.Areas.Membership.Profile.CreditCard.SaveCreditCard(token, input);
            return Json(model);
        }
    }
}
